package com.yzd.learnjava.util;

import java.util.HashSet;
import java.util.Set;

public class Sets {
	public static <T> Set<T> unino(Set<T> a, Set<T> b){
		Set<T> result = new HashSet<T>(a);
		result.addAll(b);
		return result;
		
	}
	
	public static <T> Set<T> interSection(Set<T> a, Set<T> b){
		Set<T> result = new HashSet<T>(a);
		result.retainAll(b);
		return result;
		
	}
	
	public static <T> Set<T> difference(Set<T> superSet, Set<T> subSet){
		Set<T> result = new HashSet<T>(superSet);
		result.removeAll(subSet);
		return result;
		
	}
	
	public static <T> Set<T> complement(Set<T> a, Set<T> b){
		return difference(unino(a, b), difference(a, b));
		
	}
}
